:root {
    --talon-green: #1a3a32;
    --green: #203c26;
    --white: #ffffff;
    --lightgreen: #2c5234;
    --accent: #8B4513;
    --correct-green: #6d9673;
    --error-red: #a34a4a;
    --tile-size: 40px;
    --tile-max-size: 40px;
}

/* 1. Main Layout */
.game-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 20px 50px 20px; /* Large bottom padding for the fixed keyboard */
    font-family: 'Georgia', serif;
    margin-top: 30px;
    margin-bottom: 30px;

}

.game-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 2. Master Password Section (Top) */
.master-section {
    background: var(--green);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #ddd;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.master-password-box {
    margin-top: 20px;
    padding: 20px;
    background: var(--green);
    border-radius: 8px;
    transition: all 0.4s ease;
}

.master-password-box h3 {
    text-align: center;
    color: var(--white);
    font-size: 2rem;
    margin-bottom: 30px;
}

.password-grid {
    display: flex;
    flex-wrap: nowrap; 
    gap: 4px;
    justify-content: center;
    width: 100%;
    overflow-x: auto;
    padding: 5px;
}

.hidden {
    display: none !important;
}

/* 3. Clues Grid (2-Wide) */
.clues-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 Wide */
    gap: 20px;
}

.clue-card {
    background: var(--lightgreen);
    padding: 20px;
    border-radius: 8px;
    border-left: 6px solid var(--accent); /* Brown accent for style */
    box-shadow: 2px 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.clue-card p {
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 15px;
    color: var(--white);
    font-weight: 500;
}

/* 4. The Tiles */
.slot-wrapper {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 5px;
}

.tile {
    touch-action: manipulation;
    flex: 0 1 var(--tile-max-size);
    aspect-ratio: 1 / 1;
    min-width: 25px;
    font-size: clamp(1rem, 4vw, 1.4rem);
    background: white;
    border: 2px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: bold;
    font-family: Georgia, 'Times New Roman', Times, serif;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    border-radius: 4px;
}

.tile.master-tile {
    border-bottom: 4px solid var(--talon-green);
    background-color: #fffdf5;
}

.tile.selected {
    border: 3px solid var(--talon-green);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    z-index: 5;
}

.tile.correct {
    background-color: var(--correct-green);
    color: white;
    border-color: var(--correct-green);
}

.tile.incorrect {
    background-color: var(--error-red);
    color: white;
    border-color: var(--error-red);
}

.tile-space {
    width: 20px;
}

/* 5. Fixed Bottom Keyboard */
.keyboard-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(1, 27, 21, 0.815); /* Heavy Talon Green */
    padding: 40px 0 20px 0;
    box-shadow: 0 -8px 25px rgba(0,0,0,0.4);
    z-index: 1000;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.keyboard-row {
    display: flex;
    gap: 6px;
    width: 100%;
    justify-content: center;
}

.key {
    touch-action: manipulation;
    height: 45px;
    min-width: 35px;
    padding: 0 12px;
    background: var(--white);
    color: var(--talon-green);
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: max(1rem, 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.key.large {
    min-width: 65px;
    background: #e0e0e0;
}

.key:hover {
    background: #d4d4d4;
}

.key svg {
    width: 20px;
    height: 20px;
}

.close-keyboard-btn {
    position: absolute;
    top: 0px;
    right: 0px;
    background: none;
    border: none;
    color: var(--white);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    z-index: 1001;
    transition: transform 0.2s;
}

.close-keyboard-btn:hover {
    transform: scale(1.2);
    color: var(--error-red);
}

/* 6. Controls & Buttons */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.submit-btn { background-color: var(--correct-green); color: var(--white); } /* Gold for Submit */
.clear-btn { background-color: #666; }
.restart-btn { background-color: var(--error-red); }

/* 7. Alerts */
.alert-container {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
}

.alert {
    background: white;
    color: var(--talon-green);
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 2px solid var(--talon-green);
    text-align: center;
    margin-bottom: 15px;
}

.alert.hide {
    opacity: 0;
    outline: none;
}

/* 8. Mobile Responsiveness */
@media (max-width: 850px) {
    .clues-grid {
        grid-template-columns: 1fr;
    }
    
    .key {
        min-width: 25px;
        height: 40px;
        padding: 0 6px;
        font-size: 16px;
    }

    .game-wrapper {
        padding-bottom: 280px;
    }
}

@media (max-width: 420px) {
    .game-wrapper {
        padding-left: 10px;
        padding-right: 10px;
    }

    .tile {
        flex: 1 1 32px; 
        max-width: 32px; 
        min-width: 20px;
        aspect-ratio: 1 / 1;
        font-size: 1rem;
        border-width: 1.5px;
    }

    .slot-wrapper, .password-grid {
        display: flex;
        flex-wrap: nowrap;
        gap: 2px;
        justify-content: center;
        width: 100%;
        overflow: hidden;
    }

    .tile-space {
        width: 8px; 
        flex-shrink: 0;
    }

    .keyboard-container {
        padding-bottom: 15px;
    }

    .key {
        height: 40px;
        min-width: 25px;
    }

    .key.large {
        min-width: 45px;
    }

    .clue-card p {
        font-size: 0.95rem;
    }
}